package com.tj.jinzao.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.tj.jinzao.R;
import com.tj.jinzao.base.BaseFragment;
import com.tj.jinzao.callback.IListGroupView;
import com.tj.jinzao.common.Constant;
import com.tj.jinzao.model.ResultResponse;
import com.tj.jinzao.model.User;
import com.tj.jinzao.presenter.PersonPresenter;
import com.tj.jinzao.widgets.RoundedImageView;

import butterknife.BindView;

public class PersonMangerFragment extends BaseFragment<PersonPresenter> implements IListGroupView<User> {
    protected final static String ARG_TAG_ID = "tagId";
    protected final static String ARG_LOAD_ID = "load_id";
    private String chatId;
    @BindView(R.id.iv_head)
    RoundedImageView iv_head;
    @BindView(R.id.nickName)
    TextView nickName;
    @BindView(R.id.sex)
    TextView sex;
    @BindView(R.id.birthday)
    TextView birthday;
    @BindView(R.id.height)
    TextView height;
    @BindView(R.id.healthy)
    TextView healthy;

    public static PersonMangerFragment newInstance() {
        PersonMangerFragment fragment = new PersonMangerFragment();
        if (fragment != null) {
            Bundle args = new Bundle(3);
            args.putString(ARG_TAG_ID, "1");
            args.putInt(ARG_LOAD_ID, 1);
            args.putInt(ARG_LAYOUT_RES_ID, R.layout.person_fragment);
            fragment.setArguments(args);
        }

        return fragment;
    }

    @Override
    protected PersonPresenter createPresenter() {
        return new PersonPresenter(this);
    }

    @Override
    protected void setupViews(LayoutInflater inflater, View view) {
        chatId=getActivity().getIntent().getStringExtra("id");
        mPresenter.getPersonData(chatId);

    }


    @Override
    public void onCreateGroupSuccess(User friendBean) {
        displayImage(Constant.IMAGE_PREFIX+friendBean.getImgurl(),iv_head);
        nickName.setText(friendBean.getNickname());
        if(friendBean.getGender()==1){
            sex.setText("男");
        }else {
            sex.setText("女");
        }
        birthday.setText(friendBean.getBirthday());
        height.setText(friendBean.getHeight());
        healthy.setText(friendBean.getFamilyHealth());
    }

    @Override
    public void onFailed(ResultResponse response) {

    }


    @Override
    public void onRequestSuccess(User personBean) {

    }

    @Override
    public void onRequestNoData(String message) {

    }

    @Override
    public void onRequestError(String error_message) {

    }
}
